package com.edu.common.utils;

import cn.hutool.core.util.StrUtil;
import java.net.InetAddress;

/**
 * 处理并记录日志文件
 *
 * @author xxxx
 */
public class LogUtils {
    public static String getBlock(Object msg) {
        if (msg == null) {
            msg = "";
        }
        return "[" + msg.toString() + "]";
    }

    public static String getLocalHostIp(){
        String ip = "";
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            ip = inetAddress.getHostAddress();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ip;
    }

    public static String mergeHost(String imageHost, String path){
        if(StrUtil.startWith(path, "/dev-api")){
            path = path.replace("/dev-api", "");
        }
        if(StrUtil.startWith(path, "/prod-api")){
            path = path.replace("/prod-api", "");
        }
        return imageHost + path;
    }

}
